// $codepro.audit.disable largeNumberOfParameters, declareAsInterface
/**
 * 
 */
package edu.gatech.datastorage;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Structure for containing patient information such as name, 
 * gender, age, address, etc.  Object is then stored in the 
 * field <code>info</code> in the <code>Patient</code> class.
 * @author Dan Holdridge
 * @version 1.0
 */
public class PatientInformation implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 170652531345040299L;

	//TODO are Name and Password going to be classes?
	/**
	 * String: patient's name
	 */
	private String name;
	
	/**
	 * String: patient's password
	 */
	private String password;
	
	/**
	 * int: Patient's age
	 */
	private int age;
	
	/**
	 * Gender: Patient's gender
	 */
	private Gender gender;
	
	/**
	 * String: patient's primary phone number
	 */
	private String phoneNumber;
	
	/**
	 * String: patient's address
	 */
	private String address;
	
	/**
	 * String: patient's pharmacy of choice
	 */
	private String pharmacy;
	
	/**
	 * String: patient's insurance provider
	 */
	private String insurance;
	
	/**
	 * String: patient's date of birth
	 */
	private String dateOfBirth;
	
	/**
	 * List: All of the patient's treatment records, one for each visit
	 */
	private List<TreatmentRecord> history = new ArrayList<TreatmentRecord>();

	/**
	 * Collection: all of the patient's medications
	 */
	private Collection<String> medication;
	
	/**
	 * Collection: all of the patient's allergies
	 */
	private Collection<String> allergies;
	
	/**
	 * int: how much the patient owes the office in dollars
	 */
	private int amountOwed;
	
	/**True if a patient has an appointment pending so
	 * they cannot create a bunch of appointments
	 */
	private boolean pendingAppointment;
	
	/**
	 * 
	 * @param name
	 * @param password
	 * @param age
	 * @param gender
	 * @param phoneNumber
	 * @param address
	 * @param pharmacy
	 * @param insurance
	 * @param medication
	 * @param allergies
	 * @param dateOfBirth
	 */
	public PatientInformation(String name, String password, int age, 
			Gender gender, String phoneNumber, String address, String 
			pharmacy, String insurance, Collection<String> medication, 
			Collection<String> allergies, String dateOfBirth){

		this.name = name;
		this.password = password;
		this.age = age;
		this.gender = gender;
		this.phoneNumber = phoneNumber;
		this.address = address;
		this.pharmacy = pharmacy;
		this.insurance = insurance;
		this.medication = medication;
		this.allergies = allergies;
		this.dateOfBirth = dateOfBirth;
	}
	
	/**
	 * Constructor used for a registering patient
	 * @param name
	 * @param password
	 */
	public PatientInformation(String name, String password){
		this.name = name;
		this.password = password;
		final ArrayList<String> meds = new ArrayList<String>();
		meds.add("Medications");
		final ArrayList<String> allergies = new ArrayList<String>();
		allergies.add("Allergies");
		final int age = 0; // $codepro.audit.disable variableUsage
		this.medication = meds;
		this.allergies = allergies;
		this.gender = Gender.MALE;
		this.phoneNumber = "Phone Number";
		this.address = "Address";
		this.pharmacy = "pharmacy";
		this.insurance = "Insurance";
		this.dateOfBirth = "Date of Birth";
	}
	
	/**
	 * Adds a treatment record to the history.
	 * 
	 * @param record The new TreatmentRecord
	 */
	public void addRecord(TreatmentRecord record){
		this.history.add(record);
	}
	
	/**
	 * Finds the most recent treatment record
	 * @return The TreatmentRecord at the end of the 
	 * history array.
	 */
	public TreatmentRecord getLastRecord(){
		if(history.size() > 0){
			return this.history.get(history.size() - 1);
		}
		else{
			return null;
		}
	}
	
	/**
	 * Deletes the most recent record
	 */
	public void deleteLastRecord(){
		if(history.size() > 0){
			history = history.subList(0, history.size() - 1);
		}
	}

	/**
	 * @see java.lang.Object#toString()
	 * @return The name of the patient
	 */
	public String toString(){
		return "Name: " + name + "\n" + "Age: " + age + "\n" + "Phone number: "
		+ phoneNumber + "\n" 
		+ "Address: " + address + "\n" + "Insurance: " + insurance + "\n" + 
		"Pharmacy: " + pharmacy + "\n" + 
		"Medications: " + medication.toString() + "\n" + "Allergies: " + 
		allergies.toString() + "\n" + 
		"Date of birth: " + dateOfBirth;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * @param age the age to set
	 */
	public void setAge(int age) {
		this.age = age;
	}

	/**
	 * @return the gender
	 */
	public Gender getGender() {
		return gender;
	}

	/**
	 * @param gender the gender to set
	 */
	public void setGender(Gender gender) {
		this.gender = gender;
	}

	/**
	 * @return the phoneNumber
	 */
	public String getPhoneNumber() {
		return phoneNumber;
	}

	/**
	 * @param phoneNumber the phoneNumber to set
	 */
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * @return the pharmacy
	 */
	public String getPharmacy() {
		return pharmacy;
	}

	/**
	 * @param pharmacy the pharmacy to set
	 */
	public void setPharmacy(String pharmacy) {
		this.pharmacy = pharmacy;
	}

	/**
	 * @return the insurance
	 */
	public String getInsurance() {
		return insurance;
	}

	/**
	 * @param insurance the insurance to set
	 */
	public void setInsurance(String insurance) {
		this.insurance = insurance;
	}

	/**
	 * @return the dateOfBirth
	 */
	public String getDateOfBirth() {
		return dateOfBirth;
	}

	/**
	 * @param dateOfBirth the dateOfBirth to set
	 */
	public void setDateOfBirth(String dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	/**
	 * @return the history
	 */
	public List<TreatmentRecord> getHistory() {
		return history;
	}

	/**
	 * @param history the history to set
	 */
	public void setHistory(List<TreatmentRecord> history) {
		this.history = history;
	}

	/**
	 * @return the medication
	 */
	public Collection<String> getMedication() {
		return medication;
	}

	/**
	 * @param medication the medication to set
	 */
	public void setMedication(Collection<String> medication) {
		this.medication = medication;
	}

	/**
	 * @return the allergies
	 */
	public Collection<String> getAllergies() {
		return allergies;
	}

	/**
	 * @param allergies the allergies to set
	 */
	public void setAllergies(Collection<String> allergies) {
		this.allergies = allergies;
	}

	/**
	 * @return the amountOwed
	 */
	public int getAmountOwed() {
		return amountOwed;
	}

	/**
	 * @param amountOwed the amountOwed to increment
	 */
	public void setAmountOwed(int amountOwed) {
		this.amountOwed += amountOwed;
	}
	
	/**Sets the status of a pending appointment
	 * @param pendingAppointment
	 */
	public void setPendingAppointment(boolean pendingAppointment) {
		this.pendingAppointment = pendingAppointment;
	}
	
	/**
	 * 
	 * @return boolean containing patient appointment status
	 */
	public boolean hasPendingAppointment() {
		return pendingAppointment;
	}
	
}
